<%-- 
    Document   : register
    Created on : Oct 17, 2011, 10:55:52 PM
    Author     : NGUYEN CONG BINH
--%>

<%@page import="POJO.SanPhamPOJO"%>
<%@page import="java.util.ArrayList"%>
<%@page import="POJO.NguoiDungPOJO"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>


<!--Hiện tên Đăng Nhập-->
<%
    // String tenDangNhap = "[bạn chưa đăng nhập]";
    if (session.getAttribute("KhachHang") != null) {
        NguoiDungPOJO kh = (NguoiDungPOJO) session.getAttribute("KhachHang");%>           
<div  align="right">
    <h3> Xin chào: <strong> <%= kh.getTenDangNhap()%></strong> </h3> 
    <a  href="LoginController?Action=Logout">Đăng xuất </a>
</div>             
<%} else {%>
<div  align="right">
    <a  href="LoginController?Action=View">Bạn chưa đăng nhập! </a>
</div> 
<% }%>
<!--Kết thúc phần Đăng Nhập-->
<article class="cdp-tab clearfix">
    <ul class="lstitle-cdp-tab clearfix" id="ul1">
        <li class="active"><a  href="#"> GIỎ HÀNG:  </a></li> 
    </ul> 	
    <div class="cdp-tab-inside">
        <form action="#" method="get"  name="Gio_hang">
            <ul class="clearfix" id="dien_thoai" style="">
                <%--Bắt đầu giỏ hàng  --%>

                <li>
                    <!--Hiện thông báo lỗi -->
                    <%
                        if (request.getAttribute("Error") != null) {%>
                    <div align="center"> 
                        <font face="Tahoma, Geneva, sans-serif" size="+1" color="#FF0000"><% out.println(request.getAttribute("Error"));%>  </font>
                    </div>
                    <%}%>
                    <!--Kết thúc thông báo lỗi -->                    
                    <table width="700" height="119" border="1" align="center" cellpadding="0" cellspacing="0"  bordercolor="#000000">

                        <tr bgcolor="#BDFDFC">
                            <td width="12%" height="44" align="center">Xóa</td>
                            <td width="28%" align="center">Tên sản phẩm</td>
                            <td width="20%" align="center">Số lượng</td>
                            <td width="20%" align="center">Đơn giá</td>
                            <td width="20%" align="center">Thành tiền</td>
                        </tr>
                        <%
                            double tongTien = 0;
                            if (session.getAttribute("GioHang") != null) {
                                ArrayList<SanPhamPOJO> gioHang = (ArrayList<SanPhamPOJO>) session.getAttribute("GioHang");

                                for (int i = 0; i < gioHang.size(); i++) {
                                    SanPhamPOJO sp = gioHang.get(i);
                                    double tongCong = sp.getSoLuong() * sp.getGiaBan();
                                    tongTien += tongCong;
                        %>     
                        <tr>
                            <td height="31" align="center"><a href="ShoppingCartController?Action=DeleteItem&MaSanPham=<%=sp.getMaSanPham()%>"><img  alt="delete" src="Images/Images_css_files/delete_bt.gif"></a></td>
                            <td> <%=sp.getMaSanPham()%> | <%=sp.getTenSanPham()%></td>
                            <td> <input name="tb_soluong" type="text" id="tb_soluong" size="1" value="<%= sp.getSoLuong()%>"></td>
                            <td><%= sp.getGiaBan()%> $</td>
                            <td><%= sp.getGiaBan() * sp.getSoLuong()%> $</td>
                        </tr>
                        <%
                                }
                            }
                        %>  
                        <tr bgcolor="#BDFDFC">
                            <td height="42" align="center">&nbsp</td>
                            <td>&nbsp;</td>
                            <td>&nbsp;</td>
                            <td><strong>Tổng tiền:</strong></td>
                            <td> <font face="Tahoma, Geneva, sans-serif" size="+1" color="blue"><%=tongTien%> $</font>

                            </td>
                        </tr>
                    </table>
                    <table width="700" height="20" border="0"  align="center" cellpadding="0" cellspacing="0" >
                        <tr>
                            <td width="25%" height="37" align="center"><a href="HomeController?Action=View"> <input type="button" name="bt_tieptucmua" id="bt_tieptucmua" value="Tiếp tục mua" ></a></td>
                            <td width="25%" align="center"><a href="ShoppingCartController?Action=DeleteAll"><input type="button" name="bt_xoatatca" id="bt_xoatatca" value="Xóa tất cả"></a></td>
                            <td width="25%" align="center"><a href="ShoppingCartController?Action=Update"><input type="submit" name="bt_capnhat" id="bt_capnhat" value="Cập nhật"></a></td>
                            <td width="25%" align="center"><a href="ShoppingCartController?Action=SaveShoppingCart"><input type="submit" name="bt_luugiohang" id="bt_luugiohang" value="Lưu giỏ hàng"></a></td>
                        </tr>
                        <tr>
                            <td colspan="4">
                            </td>
                        </tr>
                    </table>
                </li> 

                <%--Kết thúc giỏ hàng  --%>
            </ul>
        </form>   
</article>









